
<html><head>
<title>translation - flibs</title>
<style type="text/css"><!--
    HTML {
	background: 	#FFFFFF;
	color: 		black;
    }
    BODY {
	background: 	#FFFFFF;
	color:	 	black;
    }
    DIV.doctools {
	margin-left:	10%;
	margin-right:	10%;
    }
    DIV.doctools H1,DIV.doctools H2 {
	margin-left:	-5%;
    }
    H1, H2, H3, H4 {
	margin-top: 	1em;
	font-family:	sans-serif;
	font-size:	large;
	color:		#005A9C;
	background: 	transparent;
	text-align:		left;
    }
    H1.title {
	text-align: center;
    }
    UL,OL {
	margin-right: 0em;
	margin-top: 3pt;
	margin-bottom: 3pt;
    }
    UL LI {
	list-style: disc;
    }
    OL LI {
	list-style: decimal;
    }
    DT {
	padding-top: 	1ex;
    }
    UL.toc,UL.toc UL, UL.toc UL UL {
	font:		normal 12pt/14pt sans-serif;
	list-style:	none;
    }
    LI.section, LI.subsection {
	list-style: 	none;
	margin-left: 	0em;
	text-indent:	0em;
	padding: 	0em;
    }
    PRE {
	display: 	block;
	font-family:	monospace;
	white-space:	pre;
	margin:		0%;
	padding-top:	0.5ex;
	padding-bottom:	0.5ex;
	padding-left:	1ex;
	padding-right:	1ex;
	width:		100%;
    }
    PRE.example {
	color: 		black;
	background: 	#f5dcb3;
	border:		1px solid black;
    }
    UL.requirements LI, UL.syntax LI {
	list-style: 	none;
	margin-left: 	0em;
	text-indent:	0em;
	padding:	0em;
    }
    DIV.synopsis {
	color: 		black;
	background: 	#80ffff;
	border:		1px solid black;
	font-family:	serif;
	margin-top: 	1em;
	margin-bottom: 	1em;
    }
    UL.syntax {
	margin-top: 	1em;
	border-top:	1px solid black;
    }
    UL.requirements {
	margin-bottom: 	1em;
	border-bottom:	1px solid black;
    }
--></style>
</head>
<! -- Generated from file 'translation.man' by tcllib/doctools with format 'html'
   -->
<! -- Copyright &copy; 2016 Arjen Markus &lt;arjenmarkus at sourceforge dot net&gt;
   -->
<! -- CVS: $Id: translation.html,v 1.1 2016/11/20 12:58:39 arjenmarkus Exp $ translation.n
   -->
<body><div class="doctools">
<h1 class="title">translation(n) 1.0  &quot;flibs&quot;</h1>
<div id="name" class="section"><h2><a name="name">Name</a></h2>
<p>translation - Provide in-source lookup tables for strings in different languages</p>
</div>
<div id="toc" class="section"><h2><a name="toc">Table Of Contents</a></h2>
<ul class="toc">
<li class="section"><a href="#toc">Table Of Contents</a></li>
<li class="section"><a href="#synopsis">Synopsis</a></li>
<li class="section"><a href="#section1">Description</a></li>
<li class="section"><a href="#section2">ROUTINES</a></li>
<li class="section"><a href="#section3">AUXILIARY PROGRAM</a></li>
<li class="section"><a href="#copyright">Copyright</a></li>
</ul>
</div>
<div id="synopsis" class="section"><h2><a name="synopsis">Synopsis</a></h2>
<div class="synopsis">
<ul class="syntax">
<li><a href="#1"><b class="cmd">call set_language( lang )</b></a></li>
<li><a href="#2"><b class="cmd">call get_text( keyword, text, found )</b></a></li>
</ul>
</div>
</div>
<div id="section1" class="section"><h2><a name="section1">Description</a></h2>
<p>The purpose of the <i class="term">translation</i> module is to embed text strings in different languages in the
source code and to look them up for a particular language. The strings are characterised by a keyword.
The module comes with an auxiliary program, <i class="term">mktranslation.f90</i>, that converts an input
file into Fortran source code to populate the arrays that hold the strings.</p>
<p>The input file for the auxiliary program is very simple in structure:</p>
<ul class="itemized">
<li><p>The hash character(\#) introduces a comment, anything after that is ignored.</p></li>
<li><p>A line starting with &quot;default:&quot; indicates the default language to use.</p></li>
<li><p>A line containing the word &quot;key:&quot; at the start is considered the start of a new keyword.</p></li>
<li><p>Any other line holding a colon (:) is considered the string to be used for the previous keyword and
the language given by the substring before the colon.</p></li>
</ul>
<p>Here is a small example:</p>
<pre class="example">
# Note: The translations are not necessarily correct - just serve as illustrations
# Note: The keywords are case-sensitive!
#
default: EN
key: FileNotFound
EN: The file was not found:
NL: Het bestand is niet gevonden:
DE: Die Datei ist nicht gefunden:
FR: Le fichier n'etait pas trouve:
key: ErrorReadingFile
EN: Error while reading the file
NL: Fout bij het lezen van het bestand
DE: Fehler weil das Datei wurde gelesen
FR: Erreur pendant que le fichier etait lu
</pre>
<p>This file is then read by the <i class="term">mktranslation</i> program and the result is in the file <i class="term">translation.inc</i>
for inclusion in the <i class="term">translation</i> module. Using the functions <i class="term">set_language</i> and <i class="term">get_text</i>
the program can then select in which language the text strings should be displayed:</p>
<pre class="example">
    use translation
    call set_language( 'FR' )
    ...
    if ( file_not_found ) then
        call get_text( 'FileNotFound', text, found )
        write(*,*) trim(text)
    endif
</pre>
</div>
<div id="section2" class="section"><h2><a name="section2">ROUTINES</a></h2>
<p>There are two public routines:</p>
<dl class="definitions">
<dt><a name="1"><b class="cmd">call set_language( lang )</b></a></dt>
<dd><p>This subroutine sets the language to be used for looking up the required translation. If such a translation
is not available, the string belonging to the default language will be returned instead.</p>
<dl class="arguments">
<dt>character(len=*), intent(in) <i class="arg">lang</i></dt>
<dd><p>Language to be used (nothing more than a convenient string, like &quot;EN&quot; or &quot;FR&quot;). It is used as case-sensitive.</p></dd>
</dl></dd>
<dt><a name="2"><b class="cmd">call get_text( keyword, text, found )</b></a></dt>
<dd><p>This subroutine looks up the string that belongs to the combination of keyword and language.
If that combination is not found, it returns the string for the keyword and the default language.
If no such string is available either, the keyword is returned and the argument <i class="term">found</i> is set to <i class="term">false</i>.</p>
<dl class="arguments">
<dt>character(len=*), intent(in) <i class="arg">keyword</i></dt>
<dd><p>The keyword to be looked up.</p></dd>
<dt>character(len=*), intent(out) <i class="arg">text</i></dt>
<dd><p>The variable to hold the text string that was to be looked up.</p></dd>
<dt>logical, intent(out), optional <i class="arg">found</i></dt>
<dd><p>If present, set to <i class="term">false</i> if the keyword was not found, otherwise to <i class="term">true</i>.</p></dd>
</dl></dd>
</dl>
<p><em>Note:</em> In combination with the <i class="term">flexoutput</i> module, you can use it to create format strings
that are adapted to the language of choice.</p>
</div>
<div id="section3" class="section"><h2><a name="section3">AUXILIARY PROGRAM</a></h2>
<p>The auxiliary program can be used to convert an input file using the described keywords into an
include file as used by the <i class="term">translation</i> module.</p>
<p>The use of the program is very simple:</p>
<pre class="example">
    mktranslation &quot;name-of-input-file&quot;
</pre>
<p>It writes the file <i class="term">translation.inc</i> based on the information in the input file.</p>
</div>
<div id="copyright" class="section"><h2><a name="copyright">Copyright</a></h2>
<p>Copyright &copy; 2016 Arjen Markus &lt;arjenmarkus at sourceforge dot net&gt;</p>
</div>
</div></body></html>